<!DOCTYPE html>
<html>

<head>
    <title>登录</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
            min-height: 100vh;
            margin: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            background: linear-gradient(135deg, #f0f4f9 0%, #e3eaf3 100%);
            position: relative;
            overflow: hidden;
        }

        /* 渐变背景动画 */
        .tech-background {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            overflow: hidden;
            z-index: 1;
            background: linear-gradient(-45deg, #e3eaf3, #f0f4f9, #e8f0f5, #edf3f8);
            background-size: 400% 400%;
            animation: gradientBG 15s ease infinite;
        }

        @keyframes gradientBG {
            0% {
                background-position: 0% 50%;
            }

            50% {
                background-position: 100% 50%;
            }

            100% {
                background-position: 0% 50%;
            }
        }


        .info {
            color: #546e7a;
            margin: 1rem 0 1.5rem;
            text-align: center;
            font-size: 0.95rem;
            line-height: 1.5;
            position: relative;
            padding: 0.75rem;
            border-radius: 8px;
            background: rgba(81, 145, 95, 0.05);
            border: 1px solid rgba(81, 145, 95, 0.1);
        }

        /* 装饰元素样式 */
        .tech-circle {
            position: absolute;
            border-radius: 50%;
            background: linear-gradient(45deg, rgba(81, 145, 95, 0.2), rgba(81, 145, 95, 0.05));
            animation: pulse 4s ease-in-out infinite;
        }

        .tech-circle:nth-child(1) {
            width: 300px;
            height: 300px;
            top: -150px;
            right: -150px;
            background: linear-gradient(45deg, rgba(81, 145, 95, 0.15), rgba(81, 145, 95, 0.05));
            animation-delay: 0s;
        }

        .tech-circle:nth-child(2) {
            width: 400px;
            height: 400px;
            bottom: -200px;
            left: -200px;
            background: linear-gradient(-45deg, rgba(81, 145, 95, 0.1), rgba(81, 145, 95, 0.03));
            animation-delay: -2s;
        }

        @keyframes pulse {
            0% {
                transform: scale(1);
                opacity: 0.5;
            }

            50% {
                transform: scale(1.1);
                opacity: 0.7;
            }

            100% {
                transform: scale(1);
                opacity: 0.5;
            }
        }

        .login-container {
            background: rgba(255, 255, 255, 0.9);
            padding: 2.5rem;
            border-radius: 16px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
            backdrop-filter: blur(8px);
            border: 1px solid rgba(255, 255, 255, 0.8);
            width: 100%;
            max-width: 400px;
            margin: 1rem;
            position: relative;
            z-index: 2;
            animation: containerAppear 0.6s ease-out;
        }

        @keyframes containerAppear {
            from {
                transform: translateY(20px);
                opacity: 0;
            }

            to {
                transform: translateY(0);
                opacity: 1;
            }
        }

        h1 {
            margin: 0 0 1.5rem;
            color: #2c3e50;
            text-align: center;
            font-size: 1.75rem;
            font-weight: 500;
            position: relative;
            padding-bottom: 1rem;
        }

        h1::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 25%;
            width: 50%;
            height: 2px;
            background: linear-gradient(90deg, transparent, #51915f, transparent);
        }

        .form-group {
            margin-bottom: 1.5rem;
            position: relative;
        }

        label {
            display: block;
            margin-bottom: 0.5rem;
            color: #546e7a;
            font-size: 0.9rem;
            transform-origin: left;
            transition: all 0.2s ease;
        }

        input {
            width: 100%;
            padding: 0.875rem 1rem;
            background: rgba(255, 255, 255, 0.9);
            border: 1px solid #dde4e9;
            border-radius: 8px;
            font-size: 1rem;
            color: #2c3e50;
            transition: all 0.2s ease;
        }

        input:focus {
            outline: none;
            border-color: #51915f;
            background: #ffffff;
            box-shadow: 0 0 0 3px rgba(81, 145, 95, 0.1);
        }

        button {
            width: 100%;
            padding: 1rem;
            background: linear-gradient(135deg, #51915f 0%, #3d6d47 100%);
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 1rem;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s ease;
            position: relative;
            overflow: hidden;
        }

        button::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
            transition: 0.5s;
        }

        button:hover::before {
            left: 100%;
        }

        button:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(81, 145, 95, 0.2);
        }

        .error {
            color: #e74c3c;
            margin-top: 1rem;
            text-align: center;
            font-size: 0.9rem;
        }

        @media (max-width: 480px) {
            .login-container {
                margin: 1rem;
                padding: 2rem;
                background: rgba(255, 255, 255, 0.95);
            }

            h1 {
                font-size: 1.5rem;
            }
        }
    </style>
</head>

<body>
    <div class="tech-background">
        <div class="tech-circle"></div>
        <div class="tech-circle"></div>
    </div>

    <div class="login-container">
        <h1>登录配置后台</h1>
        <p class="info">欢迎使用有度插件服务</p>
        <form id="loginForm" action="/login" method="POST">
            <div class="form-group">
                <label for="password">管理员密码</label>
                <input type="password" id="password" name="password" required>
            </div>
            <button type="submit">登录</button>
            <div id="error" class="error"></div>
        </form>
    </div>

    <script>
        const form = document.getElementById('loginForm');
        const error = document.getElementById('error');

        form.addEventListener('submit', async (e) => {
            e.preventDefault();
            const password = document.getElementById('password').value;

            try {
                const response = await fetch('/login', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                    },
                    body: JSON.stringify({ password }),
                });

                const data = await response.json();
                if (response.ok) {
                    window.location.href = '/services';
                } else {
                    error.textContent = data.error || '登录失败';
                }
            } catch (err) {
                error.textContent = '登录请求失败';
            }
        });
    </script>
</body>

</html>